import { TableConfig, QueryCondition, OperationResult } from '../types';

/**
 * 数据表接口
 */
export interface IJsonTable {
    /** 获取表配置 */
    getConfig(): TableConfig;

    /** 插入数据 */
    insert(data: any): Promise<OperationResult>;

    /** 批量插入数据 */
    insertMany(data: any[]): Promise<OperationResult>;

    /** 更新数据 */
    update(conditions: QueryCondition[], data: any): Promise<OperationResult>;

    /** 删除数据 */
    delete(conditions: QueryCondition[]): Promise<OperationResult>;

    /** 查询数据 */
    find(conditions?: QueryCondition[]): Promise<OperationResult>;

    /** 查询单条数据 */
    findOne(conditions: QueryCondition[]): Promise<OperationResult>;

    /** 创建索引 */
    createIndex(field: string | string[], unique?: boolean): Promise<OperationResult>;

    /** 删除索引 */
    dropIndex(indexName: string): Promise<OperationResult>;
}
